//
// CLodCharacterManager.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CVector;

public class CLodCharacterManager {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CLodCharacterManager(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CLodCharacterManager obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CLodCharacterManager(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CLodCharacterManager() {
    this(nel3dJNI.new_CLodCharacterManager(), true);
  }

  public void reset() {
    nel3dJNI.CLodCharacterManager_reset(swigCPtr, this);
  }

  public long createShapeBank() {
    return nel3dJNI.CLodCharacterManager_createShapeBank(swigCPtr, this);
  }

  public CLodCharacterShapeBank getShapeBank(long bankId) {
    long cPtr = nel3dJNI.CLodCharacterManager_getShapeBank__SWIG_0(swigCPtr, this, bankId);
    return (cPtr == 0) ? null : new CLodCharacterShapeBank(cPtr, false);
  }

  public void deleteShapeBank(long bankId) {
    nel3dJNI.CLodCharacterManager_deleteShapeBank(swigCPtr, this, bankId);
  }

  public int getShapeIdByName(String name) {
    return nel3dJNI.CLodCharacterManager_getShapeIdByName(swigCPtr, this, name);
  }

  public CLodCharacterShape getShape(long shapeId) {
    long cPtr = nel3dJNI.CLodCharacterManager_getShape(swigCPtr, this, shapeId);
    return (cPtr == 0) ? null : new CLodCharacterShape(cPtr, false);
  }

  public boolean compile() {
    return nel3dJNI.CLodCharacterManager_compile(swigCPtr, this);
  }

  public void setMaxVertex(long maxVertex) {
    nel3dJNI.CLodCharacterManager_setMaxVertex(swigCPtr, this, maxVertex);
  }

  public long getMaxVertex() {
    return nel3dJNI.CLodCharacterManager_getMaxVertex(swigCPtr, this);
  }

  public void setVertexStreamNumVBHard(long numVBHard) {
    nel3dJNI.CLodCharacterManager_setVertexStreamNumVBHard(swigCPtr, this, numVBHard);
  }

  public long getVertexStreamNumVBHard() {
    return nel3dJNI.CLodCharacterManager_getVertexStreamNumVBHard(swigCPtr, this);
  }

  public void beginRender(IDriver driver, CVector managerPos) {
    nel3dJNI.CLodCharacterManager_beginRender(swigCPtr, this, IDriver.getCPtr(driver), driver, CVector.getCPtr(managerPos), managerPos);
  }

  public boolean addRenderCharacterKey(CLodCharacterInstance instance, SWIGTYPE_p_NLMISC__CMatrix worldMatrix, CRGBA ambient, CRGBA diffuse, CVector lightDir) {
    return nel3dJNI.CLodCharacterManager_addRenderCharacterKey(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(worldMatrix), CRGBA.getCPtr(ambient), ambient, CRGBA.getCPtr(diffuse), diffuse, CVector.getCPtr(lightDir), lightDir);
  }

  public void endRender() {
    nel3dJNI.CLodCharacterManager_endRender(swigCPtr, this);
  }

  public boolean isRendering() {
    return nel3dJNI.CLodCharacterManager_isRendering(swigCPtr, this);
  }

  public void setupNormalCorrectionMatrix(SWIGTYPE_p_NLMISC__CMatrix normalMatrix) {
    nel3dJNI.CLodCharacterManager_setupNormalCorrectionMatrix(swigCPtr, this, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(normalMatrix));
  }

  public void initInstance(CLodCharacterInstance instance) {
    nel3dJNI.CLodCharacterManager_initInstance(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance);
  }

  public void releaseInstance(CLodCharacterInstance instance) {
    nel3dJNI.CLodCharacterManager_releaseInstance(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance);
  }

  public boolean startTextureCompute(CLodCharacterInstance instance) {
    return nel3dJNI.CLodCharacterManager_startTextureCompute(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance);
  }

  public CLodCharacterTmpBitmap getTmpBitmap(short id) {
    return new CLodCharacterTmpBitmap(nel3dJNI.CLodCharacterManager_getTmpBitmap(swigCPtr, this, id), false);
  }

  public void addTextureCompute(CLodCharacterInstance instance, CLodCharacterTexture lodTexture) {
    nel3dJNI.CLodCharacterManager_addTextureCompute(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance, CLodCharacterTexture.getCPtr(lodTexture), lodTexture);
  }

  public void endTextureCompute(CLodCharacterInstance instance, long numBmpToReset) {
    nel3dJNI.CLodCharacterManager_endTextureCompute(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance, numBmpToReset);
  }

  public boolean fastIntersect(CLodCharacterInstance instance, SWIGTYPE_p_NLMISC__CMatrix toRaySpace, SWIGTYPE_p_float dist2D, SWIGTYPE_p_float distZ, boolean computeDist2D) {
    return nel3dJNI.CLodCharacterManager_fastIntersect(swigCPtr, this, CLodCharacterInstance.getCPtr(instance), instance, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(toRaySpace), SWIGTYPE_p_float.getCPtr(dist2D), SWIGTYPE_p_float.getCPtr(distZ), computeDist2D);
  }

}
